<?php

/**
 * Description of url
 *
 * @author YeFng
 */
class url 
{	
    /**
     * 跳转
     * @param string $u
     */
    static function jump($u)
	{
		ob_clean();
		header("Location: $u");
		die;
	}
    
    /**
     * 组合URL参数
     * @param string $unp 注销的
     * @param string $url
     * @return string
     */
	static function p($unp)
	{
        $query = $_SERVER["QUERY_STRING"];
		parse_str($query, $get);
        if ($_POST)
            $get = array_merge ($get, $_POST);
        
        parse_str($unp, $unarr);
        foreach($unarr as $k=>$v)
         {
            if (is_array($v))
                foreach($v as $_k=>$_v)
                   unset($get[$k][$_k]);
            else 
                unset($get[$k]);
         }
        foreach ($get as $k=>$v)
            if ($v==='')
                unset($get[$k]);
		$query = http_build_query($get);
        
        $a = explode('&', $unp);
        if ($a[0]!='')
            $query .=  "&$a[0]=";
        return  self::g($query);
	}
	
	/**
	 * 转换 " 输出
	 * @param type $url
	 */
	static function _h($url)
	{
		echo str_replace('"', '%22', $url);
	}
	/**
     *  URL的参数转换
     */
	static function g($quer)
	{
		return ROOT_URL. '?' . str_replace('"', '%22', $quer);
	}
	
	/**
	 * pic
	 */
	static function pic($path)
	{
		return self::g('u=cimg\b&f='. urlencode($path));
	}
	/**
     * order url
     */    
    static function ordering($way=null)
	{
		$way or $way = $_GET['LO']['way'];
        $way = ($way=='DESC' ? 'ASC' : 'DESC');
        return self::p('&p&LO').'&LO[way]='. $way .'&LO[col]=';
    }
}